import {
  resellList
} from "../../../api.js"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    hid_lis: false,
    num_one: 0,
    num_two: 0,
    num_three: 0,
    num_four: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    that.itin()
  },
  onShow() {
    var that = this
    that.setData({
      num_one: 0,
      num_two: 0,
      num_three: 0,
      num_four: 0
    })
    if (that.data.hid_lis) {
      that.itin()
    }
    getApp().startpage(new Date().getTime())
  },
  onHide() {
    getApp().endpage(new Date().getTime())
  },
  //列表获取
  itin() {
    var token = getApp().globalData.Store.token
    var that = this
    resellList(token).then(res => {
      var lis = res.data.data
      for (var i = 0; i < lis.length; i++) {
        if (lis[i].product_resell_state == 7) {
          that.data.num_one = that.data.num_one + 1
        }
        if (lis[i].product_resell_state <= 6) {
          that.data.num_two = that.data.num_two + 1
        }
        if (lis[i].product_resell_state == 8 || lis[i].product_resell_state == 9) {
          that.data.num_three = that.data.num_three + 1
        }
        if (lis[i].product_resell_state == 10) {
          that.data.num_four = that.data.num_four + 1
        }
      }
      that.setData({
        hid_lis: true,
        num_one: that.data.num_one,
        num_two: that.data.num_two,
        num_three: that.data.num_three,
        num_four: that.data.num_four,
      })
    })
  },
  golist(e) {
    var id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pages/consignment/consignmentList/consignmentDetails/consignmentDetails?type=' + id,
    })
  },
  gokefu(){
    wx.navigateTo({
      url: '/pages/myList/message/message?type=5',
    })
  }
})